Asc Function

Returns as an Integer, the ASCII value for the first character of a String.

Syntax

result = Asc( string )

result = stringVariable.Asc


Parameters

string

String

Any valid String expression.



Notes

The Asc function returns the code point for the first character in the String passed. Characters 0 through 127 are the standard ASCII set. They will be the same on practically every platform. Asc returns the code point for whatever encoding the string is in. If the string is in MacRoman, you get the code point specified by MacRoman, and so forth.

If you need to get the ASCII code of the first byte of the string rather than the first character, use the AscB function.


Examples

This example uses the Asc function to get the ASCII value of a character.

Dim a as Integer
a = Asc("@") //returns 64

This example gets the code point for the "‚â•" symbol

Dim s as String
Dim n as Integer
s="‚â•"
n=s.Asc

:


See Also

Chr, InStr, Left, Len, Mid, Right functions; TextEncoding class.